package com.mybatistest.mapper;

import com.mybatistest.model.UserInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserInfoMapper {
    @Select("select username, `password`, age, gender, phone from user_info")
public List<UserInfo>seleteAll();

    @Select("select username, `password`, age, gender, phone from user_info where age=14")
    public List<UserInfo>seleteByAge();


    @Select("select username, `password`, age, gender, phone from user_info where age=#{age}")
public List<UserInfo>seleteByAge2(int age);

    @Select("select id,username,age,gender,phone from user_info where id<#{userId}")
    public List<UserInfo>selectById(@Param("userId") int id);

@Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into user_info (username, `password`, age, gender, phone) values (#{username},#{password},#{age},#{gender},#{phone})")
Integer insert(UserInfo userInfo);

@Delete("delete from user_info where username=#{username}")
Integer deleteByUsername(String username);

@Update("update user_info set username=#{username} where id=#{id}")
Integer update(@Param("username") String username,@Param("id") Integer id);

}
